package com.zx.idc.backend.gui.api.commom.entity;

import com.zx.idc.backend.gui.api.commom.base.BaseIDCCommand;
import com.zx.idc.common.attributes.FTPReportDataTypeEnum;
import com.zx.idc.common.attributes.NetCommunicationFileTypeEnum;
import com.zx.idc.common.attributes.SchemaFileNameEnum;

/**
 * 上传文件实体
 *
 * @param <T> 数据对象类
 * @author rxliuli
 */
public class UploadModel<T> {

    /**
     * 要传输的数据对象
     */
    private T dataObj;

    /**
     * idcID
     */
    private String idcId;

    /**
     * 要传输的数据对象的 schema文件名
     */
    private SchemaFileNameEnum schemaFileName;

    /**
     * 上传的文件类型
     */
    private FTPReportDataTypeEnum uploadType;

    /**
     * 上传文件的目录 根据文件类型自动获取
     */
    private String uploadDir;

    /**
     * 通讯网络文件类型
     */
    private NetCommunicationFileTypeEnum fileType;

    /**
     * @param dataObj        上报的xml对象
     * @param schemaFileName schema文件名称
     * @param uploadType     上报类型
     * @param fileType       文件类型
     */
    public UploadModel(T dataObj, SchemaFileNameEnum schemaFileName, FTPReportDataTypeEnum uploadType, NetCommunicationFileTypeEnum fileType) {
        this.dataObj = dataObj;
        this.schemaFileName = schemaFileName;
        this.uploadType = uploadType;
        this.fileType = fileType;
        this.uploadDir = getUploadDir(uploadType.getType());
    }

    public T getDataObj() {
        return dataObj;
    }

    public UploadModel<T> setDataObj(T dataObj) {
        this.dataObj = dataObj;
        return this;
    }

    public String getIdcId() {
        return idcId;
    }

    public UploadModel<T> setIdcId(String idcId) {
        this.idcId = idcId;
        return this;
    }

    public SchemaFileNameEnum getSchemaFileName() {
        return schemaFileName;
    }

    public UploadModel<T> setSchemaFileName(SchemaFileNameEnum schemaFileName) {
        this.schemaFileName = schemaFileName;
        return this;
    }

    public FTPReportDataTypeEnum getUploadType() {
        return uploadType;
    }

    public UploadModel<T> setUploadType(FTPReportDataTypeEnum uploadType) {
        this.uploadType = uploadType;
        this.uploadDir = getUploadDir(uploadType.getType());
        return this;
    }

    public NetCommunicationFileTypeEnum getFileType() {
        return fileType;
    }

    public UploadModel<T> setFileType(NetCommunicationFileTypeEnum fileType) {
        this.fileType = fileType;
        return this;
    }

    private String getUploadDir(String uploadType) {
        return BaseIDCCommand.getUploadPath(uploadType);
    }

    public String getUploadDir() {
        return uploadDir;
    }

    public UploadModel<T> setUploadDir(String uploadDir) {
        this.uploadDir = uploadDir;
        return this;
    }
}
